package service

import (
	"organoid_public/domain/sample/model"
	"organoid_public/domain/sample/repository"
	"organoid_public/pkg/logger"
)

type ProtocolService struct {
	log          logger.Logger
	protocolRepo repository.Protocol
}

func NewProtocolService(log logger.Logger, protocolRepo repository.Protocol) ProtocolServiceInterface {
	return &ProtocolService{
		log:          log,
		protocolRepo: protocolRepo,
	}
}

func (p *ProtocolService) ProtocolDetail(sampleId string) ([]model.SampleProtocolProcess, []model.SampleProtocolMedium, []model.SampleProtocolKeyNode, []model.SampleProtocolMaterial, error) {
	processList, err := p.protocolRepo.ProcessList(sampleId)
	if err != nil {
		return nil, nil, nil, nil, err
	}
	mediumList, err := p.protocolRepo.MediumList(sampleId)
	if err != nil {
		return nil, nil, nil, nil, err
	}
	materialList, err := p.protocolRepo.MaterialList(sampleId)
	if err != nil {
		return nil, nil, nil, nil, err
	}
	keyNodeList, err := p.protocolRepo.KeyNodeList(sampleId)
	if err != nil {
		return nil, nil, nil, nil, err
	}
	return processList, mediumList, keyNodeList, materialList, nil
}
